package cn.wsalix.sys.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.anlaser.service.impl.CommonServiceImpl;
import cn.wsalix.admin.form.LogForm;
import cn.wsalix.sys.entity.Log;
import cn.wsalix.sys.repository.LogRepository;
import cn.wsalix.sys.service.LogService;
import cn.anlaser.utils.SearchFilter;
import cn.anlaser.utils.SearchFilter.Operator;

@Service("logService")
public class LogServiceImpl extends CommonServiceImpl<LogForm,LogRepository, Log>
		implements LogService {
	@Autowired
	private LogRepository logRepository;

	@Override
	public String module() {
		return "/sys/log";
	}

	@Override
	public LogRepository getRepository() {
		return logRepository;
	}

	@Override
	public Class<Log> getEntityClazz() {
		return Log.class;
	}

	@Override
	public Map<String, SearchFilter> buildByForm(LogForm form) {
		Map<String, SearchFilter> filters = buildFilter();
		if (form.getCode() != null && !form.getCode().equals("")) {
			filters.put("code",
					new SearchFilter("code", Operator.EQ, form.getCode()));
		}
		if (form.getName() != null && !form.getName().equals("")) {
			filters.put("name",
					new SearchFilter("nama", Operator.EQ, form.getName()));
		}
		return filters;
	}

}
